home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / ELEMENTS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  12.2 KB  |  423 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // Main Header File for all DialogClass elements
  8. //
  9. // If you include this file, without including FLI.H first -- this file
  10. // will automatically include it for you
  11. //
  12.  
  13. // ==========================================================================
  14. // Consult the reference manual for complete function reference of all
  15. // functions within this header file.  All variables are documented
  16. // inside this header file, for ease of use when modifying the supplied
  17. // source code.  For additional class information, please consult the
  18. // Software Dimensions BBS.  Telephone numbers are included in the
  19. // READ.ME file and in the documentation.
  20. // ==========================================================================
  21.  
  22. #ifndef __cplusplus
  23. #error Please switch to C++ mode before using Fusion
  24. #endif
  25.  
  26. #ifdef __PASCAL__
  27. #error The Pascal calling convention cannot be used with Fusion
  28. #endif
  29.  
  30. #ifndef __FusionElements__
  31. #define __FusionElements__
  32.  
  33. #ifndef __Fusion__
  34. #include "fli.h"
  35. #endif
  36.  
  37. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  38. //
  39. // TREE OF INHERITANCE WITHIN THE DIALOG CLASS
  40. //
  41. // DialogElement
  42. //  ≥
  43. //  √ƒƒƒ CharMask * -> In FLI.H
  44. //  ≥     ¿ƒƒƒ DiaChar $
  45. //  ≥           ¿ƒƒƒ DiaCombo $
  46. //  √ƒƒƒ NumberMask * -> In FLI.H
  47. //  ≥     ¿ƒƒƒ Numerics
  48. //  ≥           √ƒƒƒ DiaInt $
  49. //  ≥           √ƒƒƒ DiaLong $
  50. //  ≥           √ƒƒƒ DiaFloat $
  51. //  ≥           √ƒƒƒ DiaDouble $
  52. //  ≥           ¿ƒƒƒ DiaBcd $
  53. //  √ƒƒƒ DiaVertRadio $
  54. //  √ƒƒƒ DiaHorizRadio $
  55. //  √ƒƒƒ DiaCheckBox $
  56. //  √ƒƒƒ DiaPushButton $
  57. //  √ƒƒƒ DiaPickGeneric $
  58. //  ≥    √ƒƒƒ DiaPickList $
  59. //  ≥    ¿ƒƒƒ DiaStructPickList $
  60. //  ¿ƒƒƒ DiaMulti $
  61. //
  62. // * CharMask/NumberMask can be found in FLI.H.  These two classes are
  63. //   also used by BlazeClass for all masked output
  64. // $ These are classes that are "plug and play" ready.  In other words,
  65. //   you can derive from these classes without any modifications.  See the
  66. //   FLI documentation for usage instructions
  67. //
  68. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  69.  
  70. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  71. //
  72. // class DiaChar
  73. //
  74. // Handles masked character based input
  75. //
  76. //
  77. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  78.  
  79. class DiaChar : public DialogElement, public CharMask
  80. {
  81. public:
  82.  
  83.   char *Value;                      // Current status of input -- contains
  84.                                     // the string with the user input
  85.  
  86.   char *Mask;                       // The character mask
  87.   char *AssembleMask;               // The character mask with all non-mask,
  88.                                     // walkaround characters stripped out
  89.  
  90.   int TotalMaskWidth;               // Actual width of the mask
  91.   int CurrentLocation;              // Current location of the input cursor
  92.  
  93.   int QuickMasked;                  // Was it quick masked?
  94.  
  95.   int AtLeft;                       // What position of string is at the left
  96.                                     // of the display?
  97.   int VisualWidth;                  // What is the visual width?
  98.  
  99.   int NoEditErase;                  // Should the cursor be reset?
  100.   int EditOverriden;                // Is edit overriden?
  101.  
  102. private:
  103.  
  104.   int Width;                        // Duplicate of Width in DialogElement
  105.                                     // class to be used only by the DiaChar
  106.                                     // class.  Used specifically for elements
  107.                                     // created by deriving the DiaChar class.
  108.  
  109. public:
  110.  
  111.   DiaChar(int,int,char *,char *,int=0,char=0,int=0,int=0);
  112.   ~DiaChar();
  113.  
  114.   void Show();
  115.   void HighLight();
  116.   void ScrollUpdate(int);
  117.  
  118.   int EventHandler(int);
  119.   int GetPhysical();
  120. };
  121.  
  122. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  123. //
  124. // class Numerics
  125. //
  126. // Base class for handling numeric mask
  127. //
  128. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  129.  
  130. class Numerics : public DialogElement, public NumberMask
  131. {
  132. public:
  133.  
  134.   char *Mask;                       // Contains the numerical mask
  135.   char *Value;                      // Contains the current value in
  136.                                     // text format
  137.  
  138.   int AllowedNegative;              // Can be negative (1) or not (0)
  139.   int AllowedBeforeDecimal;         // Number of digits before decimal
  140.   int AllowedAfterDecimal;          // Number of digits after decimal
  141.  
  142.   int CurrentLocation;              // Current location in the string
  143.   int NoEditErase;                  // Should the cursor be reset?
  144.   int EditOverriden;                // Is edit overriden?
  145.  
  146.   int EventValidation(int);
  147.   void TrimTrailingZeros();
  148.  
  149.   Numerics(int);
  150.   ~Numerics();
  151.  
  152.   void Show();
  153.   void HighLight();
  154.   int EventHandler(int Event) = 0;
  155. };
  156.  
  157. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  158. //
  159. // class DiaInt
  160. // class DiaLong
  161. // class DiaFloat
  162. // class DiaDouble
  163. // class DiaBcd
  164. //
  165. // These classes handle all numeric based input.
  166. //
  167. // Class DiaBcd is only declared if the bcd.h header file was included BEFORE
  168. // this header file
  169. //
  170. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  171.  
  172. #define Frame(ClassName,NumericType)\
  173. class ClassName : public Numerics \
  174. { \
  175. public: \
  176. \
  177.   NumericType &Value; \
  178. \
  179.   ClassName(int,int,char *,NumericType &,int=0); \
  180. \
  181.   void Show(); \
  182.   int EventHandler(int); \
  183. };
  184.  
  185. Frame(DiaInt,int);
  186. Frame(DiaLong,long);
  187. Frame(DiaFloat,float);
  188. Frame(DiaDouble,double);
  189.  
  190. #ifdef __BCD_H
  191. Frame(DiaBcd,bcd);
  192. #endif
  193.  
  194. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  195. //
  196. // class DiaHorizRadio
  197. // class DiaVertRadio
  198. //
  199. // These classes handle all radio button based input.
  200. //
  201. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  202.  
  203. #undef Frame
  204.  
  205. #define Frame(ClassName)\
  206. class ClassName : public DialogElement \
  207. { \
  208. public: \
  209. \
  210.   int &Item; \
  211.   char **Items; \
  212.   int ItemCount; \
  213.   int IsQueued; \
  214. \
  215.   ClassName(int,int,int &,int,char **); \
  216.   ~ClassName(); \
  217. \
  218.   void operator+ (char *); \
  219. \
  220.   void Show(); \
  221.   void HighLight(); \
  222.   int EventHandler(int); \
  223. };
  224.  
  225. Frame(DiaVertRadio);
  226. Frame(DiaHorizRadio);
  227.  
  228. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  229. //
  230. // class DiaCheckBox
  231. //
  232. // This class handles check box based input.
  233. //
  234. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  235.  
  236. class DiaCheckBox : public DialogElement
  237. {
  238. public:
  239.  
  240.   int &Checked;                     // Is this item checked (1) or not (0)
  241.   char *CheckText;                  // Text for next to check mark
  242.  
  243.   DiaCheckBox(int,int,int &,char *,int=0);
  244.  
  245.   void Show();
  246.   void HighLight();
  247.   int EventHandler(int);
  248. };
  249.  
  250. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  251. //
  252. // class DiaPushButton
  253. //
  254. // The ACTION element should be one of the following:
  255. //
  256. //    1000+  Send this event code along to the EventHandler() function
  257. //           of DialogClass.  At that point, the EventHandler() should
  258. //           determine the actual result of the button press
  259. //
  260. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  261.  
  262. class DiaPushButton : public DialogElement
  263. {
  264. public:
  265.  
  266.   int Action;                       // Desired action (after pressed)
  267.   int Pushed;                       // Is button in (1) or out (0)
  268.   int Active;                       // This is the active button
  269.   char *Button;                     // Text for button
  270.  
  271.   DiaPushButton(int,int,char *,int,int=0,int=0);
  272.  
  273.   void Show();
  274.   void HighLight();
  275.   int EventHandler(int);
  276.   void PushIn();
  277. };
  278.  
  279. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  280. //
  281. // class DiaPickGeneric
  282. //
  283. // This class handles all pick lists.
  284. //
  285. // This is a generic pick lister.  Just override the GetItem function call
  286. // and you can create a custom pick list style.  The GetItem function
  287. // accepts one argument that is an integer representing the item # that
  288. // is needed for this list.  The GetItem function returns a character
  289. // string that should be displayed in the list.
  290. //
  291. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  292.  
  293. class DiaPickGeneric : public DialogElement
  294. {
  295. public:
  296.  
  297.   int &Item;                        // Current item
  298.   int &ItemCount;                   // Number of items
  299.   int ItemAtTopOfList;              // Current item at the top of the list
  300.  
  301.   DiaPickGeneric(int,int,int,int,int &,int &);
  302.  
  303.   void Show();
  304.   void HighLight();
  305.   void ScrollBar();
  306.   int EventHandler(int);
  307.   int QuikFind(int,int,int);
  308.  
  309.   virtual char *GetItem(int) = 0;
  310. };
  311.  
  312. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  313. //
  314. // class DiaPickList
  315. //
  316. // This class handles all pick lists.
  317. //
  318. // This class is passed a list of CHAR elements.  For instance, the calling
  319. // program could have a "char *Mine[] = { "HELLO","THIS" };" declaration.
  320. // All you have to do is pass a pointer of MINE through ITEM and set ITEMCOUNT
  321. // to the number of elements in the array.
  322. //
  323. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  324.  
  325. class DiaPickList : public DiaPickGeneric
  326. {
  327. public:
  328.  
  329.   char **Items;                     // Text for each item
  330.  
  331.   DiaPickList(int,int,int,int,int &,int &,char **);
  332.  
  333.   char *GetItem(int);
  334. };
  335.  
  336. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  337. //
  338. // class DiaStructPickList
  339. //
  340. // This class handles all pick lists.
  341. //
  342. // This class works differently than the PICKLIST class, because it allows
  343. // you to point to a string within a structure.  Just pass a pointer to the
  344. // first element through the ITEMS argument, set the structure width through
  345. // the STRUCTWIDTH argument, and tell it how many items through the
  346. // ITEMCOUNT argument and you are off and running.
  347. //
  348. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  349.  
  350. class DiaStructPickList : public DiaPickGeneric
  351. {
  352. public:
  353.  
  354.   int StructWidth;                  // Width of the structure
  355.   void *Items;                      // Pointer to first character item
  356.                                     // in the structure array
  357.  
  358.   DiaStructPickList(int,int,int,int,int &,int &,int,void *);
  359.  
  360.   char *GetItem(int);
  361. };
  362.  
  363. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  364. //
  365. // class DiaCombo
  366. //
  367. // This class handles combo boxes -- this is a combination of a DiaChar
  368. // box and a DiaPickGeneric class.  This is a great example of the power
  369. // of the reusability of C++.  Check out DIACOMBO.CPP and see how little
  370. // code was required to pull of this new element.
  371. //
  372. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  373.  
  374. class DiaCombo : public DiaChar
  375. {
  376. public:
  377.  
  378.   int &ItemCount;                   // Number of items
  379.   int Item;                         // Current item
  380.  
  381.   DiaCombo(int,int,int &,char *,char *,int=0,char=0,int=0,int=0);
  382.  
  383.   void Show();
  384.   void HighLight();
  385.   int EventHandler(int);
  386.  
  387.   virtual char *GetItem(int) = 0;
  388. };
  389.  
  390. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  391. //
  392. // class DiaMulti
  393. //
  394. // This class handles multi line input elements.  It features a few wordstar
  395. // like commands without scroll bars.
  396. //
  397. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  398.  
  399. class DiaMulti : public DialogElement
  400. {
  401. public:
  402.  
  403.   int CurX;                         // Current X position
  404.   int CurY;                         // Current Y position
  405.   int MaxWidth;                     // Maximum width of the string
  406.   int Relative;                     // Relative position inside string
  407.  
  408.   int Start, End;                   // Starting and Ending point of string
  409.  
  410.   char *String;                     // The string where the multiline text
  411.                                     // should be placed.
  412.  
  413.   DiaMulti(int,int,int,int,char *);
  414.  
  415.   void Show();
  416.   void HighLight();
  417.   int EventHandler(int);
  418.   void Display(int);
  419.   void Triangulate(int);
  420. };
  421.  
  422. #endif
  423.